<%--
 *  File:    ComboCodeSummary.jsp
 *  @Author: Hilldao
 *  Date:    2002/1/8
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.ComboCodeSummary");
  String strTableName = "ovcombocode";
  String strModuleName = "SPM";
  String privilegeCode = "Z0607,Z0614";
%>



<%
  //get userinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");

%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="combocodesummary"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../js/FuncLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script>
parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
function clickComboCode(id)
{
  document.combocodeform.fieldid.value = id;
  parent.down.location.href = "Blank.jsp?<%= OvalTools.randomURL() %>";
}
function clickCy()
{
  if(combocodeform.cych.checked)
    combocodeform.isauto.value = "Y";
  else
    combocodeform.isauto.value = "N";
  return;
}

function page_delete()
{
	  var id = document.combocodeform.fieldid.value;
	  if(id == null || id.length == 0 || id == "" || id == "-1")
	    return;
	  var flag = confirm('<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>');
	  if(!flag)
	    return;
	  document.combocodeform.actionname.value = "delete";
	  isRunning = true;
	  document.combocodeform.submit();
}
function page_add()
{
  if(document.combocodeform.tablename.value == "-1")
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Table",false)) %>");
    return;
  }
  if(document.combocodeform.fieldname.value == "-1")
  {
    alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Field",false)) %>");
    return;
  }
  document.combocodeform.fieldid.disabled = true;
	document.combocodeform.actionname.value = "add";
	document.combocodeform.submit();
}
function page_seg()
{
  var id = document.combocodeform.fieldid.value;
	if(id == null || id.length == 0 || id == "" || id == "-1")
	   return;
  var link = "ComboCodeSegSummary.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&fieldid="+id
  <%--[SCRIPT]  alert(link);  [SCRIPT]--%>
  parent.down.location.href = link;
}

function page_summary(actionvalue,orderbyname)
{
  if(combocodeform.tablename.value=="-1")
  {
    combocodeform.tablename.value = null;
  }
  var editform = summaryPrepare(combocodeform,actionvalue,orderbyname);
  editform.action = "ComboCodeSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
</script>
<%
  cat.debug("The strCurSearchName is :" + strCurSearchName);
  cat.debug("The strCurSearchValue is :" + strCurSearchValue);
  cat.debug("The strCurOrderByCol is :" + strCurOrderByCol);
  cat.debug("The strCurOrderByType is :" + strCurOrderByType);
  cat.debug("The nCurMaxItem is :" + nCurMaxItem);
  cat.debug("The nCurCount is :" + nCurCount);
  cat.debug("The nCurPageNo is :" + nCurPageNo);
  cat.debug("The nCurTotalPage is :" + nCurTotalPage);
  cat.debug("The nCurEndIndex is :" + nCurEndIndex);
  cat.debug("The bCurHasPre is :" + bCurHasPre);
  cat.debug("The bCurHasNext is :" + bCurHasNext);
  cat.debug("The CurUserInfo is :" + CurUserInfo);

  OvalCustomTable table = new OvalCustomTable(strLanguageCode);
  OvalCustomColumn column = new OvalCustomColumn(strLanguageCode);


  Vector ComboCodeSummary = (Vector)pageContext.getAttribute("allcombocodes");
  if(ComboCodeSummary == null)
  {
    ComboCodeSummary = new Vector();
  }
  Vector alltables = (Vector)pageContext.getAttribute("alltables");
  if(alltables == null)
  {
    alltables = new Vector();
  }
  Vector allfields = (Vector)pageContext.getAttribute("allfields");
  if(allfields == null)
  {
    allfields = new Vector();
  }
  cat.debug("The ComboCodeSummary is :" + ComboCodeSummary);
  cat.debug("The alltables is :" + alltables);
  cat.debug("The allfields is :" + allfields);

%>
</head>
<body>
<table width="100%" cellspacing="0">
 <form name="combocodeform" method="post" action="../../Dispatcher"  target="_parent">
   <input type="hidden" name="pagename" value="combocodesummary">
	 <input type="hidden" name="actionname">
	 <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
	 <input type="hidden" name="orgid" value="<%=JspHelper.filterNull( CurUserInfo.get("orgid") )%>">


<table width="100%" cellspacing="0">
  <% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
</table>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
  <tr>
    <td>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">

          <tr class="deepblue-left" >
            <td width="22" class="title_center">&nbsp;</td>
            <td class="title_center" width="150"><a href="javascript:page_summary('orderby','tablename')"><%= label.getLabelName("L_Table") %></a></td>
            <td class="title_center" width="100"><a href="javascript:page_summary('orderby','fieldname')"><%= label.getLabelName("L_Field") %></a></td>
            <td class="title_center"><a href="javascript:page_summary('orderby','comments')"><%= label.getLabelName("L_Comments") %></a></td>
            <td class="title_center" width="100"><a href="javascript:page_summary('orderby','isauto')"><%= label.getLabelName("L_AutoCoding") %></a></td>
          </tr>



        <%
             int j = 0;
             String strClassType = new String();
             Integer nDefaultId = new Integer(-1);
             boolean bHasChecked = false;
          %>
          <logic:iterate id="ComboCode" collection="<%= ComboCodeSummary %>">
         <%
            HashMap ComboCodeMap = (HashMap)pageContext.getAttribute("ComboCode");

            String strIsDisabled = new String("");
            String strIsChecked = new String("");

            if(j%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "";
            }
           if(!bHasChecked)
            {
              strIsChecked = "Checked";
              bHasChecked = true;
              nDefaultId = (Integer)(ComboCodeMap.get("fieldid"));
            }
            j++;
          %>

           <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'"  onClick="javascript:radiotrue('exchangrate<%=JspHelper.filterNull(j)%>');clickComboCode('<%=JspHelper.filterNull( ComboCodeMap.get("fieldid") )%>')" class="<%=JspHelper.filterNull(strClassType)%>">
            <td width="5%">
              <input id="exchangrate<%=JspHelper.filterNull(j)%>" type="radio" name="checkdept"  value=<%=JspHelper.filterNull( ComboCodeMap.get("fieldid") )%> class="checkbox" <%=JspHelper.filterNull( strIsChecked)%> onClick="javascript:clickComboCode('<%=JspHelper.filterNull( ComboCodeMap.get("fieldid") )%>')">
            </td>
            <td>&nbsp;<%=JspHelper.filterNull( table.getTable((String)ComboCodeMap.get("tablename")) )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( column.getColumnDesc((String)ComboCodeMap.get("tablename"),(String)ComboCodeMap.get("fieldname")) )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( ComboCodeMap.get("comments") )%></td>
            <td>&nbsp;<%=JspHelper.filterNull( ComboCodeMap.get("isauto") )%></td>
          </tr>
          </logic:iterate>

          <tr>
            <td>&nbsp; </td>
            <td>
	              <%
	                 String strSelect = "";
	              %>
	              <select name="tablename" onchange="javascript:page_summary('search')">
	              <option value="-1">-----------</option>
			            <logic:iterate id="atable" collection="<%= alltables %>">
			              <%
			                HashMap a_Table = (HashMap)pageContext.getAttribute("atable");
			                String tempName = (String)a_Table.get("tablename");
			                if(tempName.equalsIgnoreCase((String)pageContext.getAttribute("tablename")))
			                  strSelect = "selected";
			                else
			                  strSelect = "";
			              %>
	              <option value = "<%=JspHelper.filterNull( a_Table.get("tablename") )%>" <%=JspHelper.filterNull( strSelect )%>>
	                 <%=JspHelper.filterNull( table.getTable((String)a_Table.get("tablename")) )%>
	              </option>
	              </logic:iterate>
	              </select>
            </td>
            <td>
	              <select name="fieldname">
	              <option value="-1">-----------</option>
			            <logic:iterate id="field" collection="<%= allfields %>">
			              <%
			                HashMap a_field = (HashMap)pageContext.getAttribute("field");
			              %>
	              <option value = "<%=JspHelper.filterNull( a_field.get("columnname") )%>">
	                 <%=JspHelper.filterNull( column.getColumnDesc((String)pageContext.getAttribute("tablename"),(String)a_field.get("columnname")) )%>
	              </option>
	              </logic:iterate>
	              </select>
             </td>
            <td>
              <input type="text" name="comments" size="30">&nbsp;&nbsp;
            </td>
            <td>
             <input type="checkbox" name="cych" onclick="javascript:clickCy();" value="checkbox" class="normalradio">
             <input type="hidden" name="isauto" value="N">
            </td>
          </tr>
          <input type="hidden" name="fieldid" value="<%=JspHelper.filterNull( nDefaultId )%>">



    <% //--------------------------------------  flipping page --%>
    <%@ include file="/inc/SummaryAction.inc" %>

      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
        <tr>
          <td class="td_center">
          <a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
          <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
          <a onclick="page_seg()"><custom:button type="1" label="L_Paragraph" imgsrc="paragraph.gif" border="0" style="width:60"/></a>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</table>
</body>
</html>


